package com.dc.refactoring._3_重新组织数据._13_ReplaceTypeCodeWithStateStrategy.step4;

public abstract class EmployeeType {
    abstract int getTypeCode();

    // 【7】将状态码和 setType() 逻辑迁移过来
    /**
     * 工程师
     */
    public static final int ENGINEER = 0;
    /**
     * 推销员
     */
    public static final int SALESMAN = 1;
    /**
     * 经理
     */
    public static final int MANAGER = 2;

    static EmployeeType newType(int type){
        switch (type) {
            case ENGINEER:
                return new Enginner();
            case SALESMAN:
                return new Salesman();
            case MANAGER:
                return new Manager();
            default:
                throw new IllegalArgumentException("无效的类型码");
        }
    }
}
